<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="__PUBLIC__/admin/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
<link href="__PUBLIC__/admin/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/select-ui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/stringOperate.js"></script>
<script>
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
var a=parent.$('#indus_admin_id').val();
function initCheckBox(){
	//将a查分为数组
	if(a.length>0){
		var a_arr=a.split(",");
		var checkAllFlag = true;
		//遍历所有的复选框将值值相等的选中
		$("[name = checkItem]:checkbox").each(function () {
			if($.inArray($(this).val(), a_arr)>-1){
				$(this).attr("checked",true);
			}else{
				checkAllFlag=false;
			}
		});
		if(checkAllFlag){
			$("[name = checkAll]:checkbox").attr("checked",true);
		}else{
			$("[name = checkAll]:checkbox").attr("checked",false);
		}
		
	}
}
$(document).ready(function(){
	initCheckBox();
	//绑定点击事件
	$("[name = checkItem]:checkbox").click(function () {
		if ($(this).is(":checked")) { //添加
			a = StringOperate.add(a,$(this).val());
			initCheckBox();
		}else{ //取消
			a = StringOperate.remove(a,$(this).val());
			$("[name = checkAll]:checkbox").attr("checked",false);
		}
	});

	//绑定点击事件
	$("[name = checkAll]:checkbox").click(function () {
		if ($(this).is(":checked")) { //添加
			$("[name = checkItem]:checkbox").each(function () {
				$(this).attr("checked",true);
				a = StringOperate.add(a,$(this).val());
			});
			
		}else{ //取消
			$("[name = checkItem]:checkbox").each(function () {
				$(this).attr("checked",false);
				a = StringOperate.remove(a,$(this).val());
			});
		}
	});

	$("#page a").click(function(){
		parent.$('#indus_admin_id').val(a);
	});
});

//关闭当前弹层并回填数据
function showclose(){
	parent.$('#indus_admin_id').val(a);
	parent.layer.close(index);
}
</script>
</head>
<body style="min-width: 100%;">
    <div class="formbody">

		<table class="tablelist">
		    <thead>
				<tr>
					<th><input name="checkAll" type="checkbox" value="" /></th>
					<th width="40%">管理员</th>
				</tr>
			</thead>
			<volist name="listinfo" id="setting">
			<tr class="forminfo">
				<td style="width:40%;"><input name="checkItem" id="checkItem" value="{$setting.admin_id}" type="checkbox"/></td>
				<td style="width:60%;">{$setting.username}</td>	
			</tr>	
			</volist>
		</table>
			{$pageshow}
		<tr><input name="btn" onclick="showclose();" class="btn" value="确认保存" 
		style="margin:20px auto;display:block; text-align:center"/></tr>
    </div>
</form>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>

</html>
